//-----------------------------------------------------------------------
// <copyright file="SanPhamServiceBase.cs" company="Pyramid Consulting">
//     Copyright (c) Pyramid Consulting. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------	

using System;
using System.Collections;
using Pyco;
using Pyco.Diagnostics;
using Pyco.Data;
using APPro.Entities;
using APPro.Data;
    
namespace APPro.Business
{   
	/// <summary>
	/// 
	/// </summary> 
    public class SanPhamServiceBase
    {
        #region SanPhamServiceBase

        public static void CreateSanPham(SanPham sanPham)
        {            
            try
            {
                SanPhamDAO sanPhamDAO = new SanPhamDAO();
                sanPhamDAO.CreateSanPham(sanPham);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SRBase.BusinessCreateSanPhamException, ex);
            }
        }

        public static void UpdateSanPham(SanPham sanPham)
        {            
            try
            {
                SanPhamDAO sanPhamDAO = new SanPhamDAO();
                sanPhamDAO.UpdateSanPham(sanPham);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SRBase.BusinessUpdateSanPhamException, ex);
            }
        }        

        public static void DeleteSanPham(string maSanPham)
        {            
            try
            {
                SanPhamDAO sanPhamDAO = new SanPhamDAO();
                sanPhamDAO.DeleteSanPham(maSanPham);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SRBase.BusinessDeleteSanPhamException, ex);
            }
        }
		
        public static SanPham GetSanPham(string maSanPham)
        {            
            try
            {
                SanPhamDAO sanPhamDAO = new SanPhamDAO();
                return sanPhamDAO.GetSanPham(maSanPham);                
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SRBase.BusinessGetSanPhamException, ex);
            }
        }                
		
        public static SanPhamCollection GetSanPhamList(SanPhamColumns orderBy, OrderDirection orderDirection)
        {            
            try
            {
                SanPhamDAO sanPhamDAO = new SanPhamDAO();
                return sanPhamDAO.GetSanPhamList(orderBy, orderDirection);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SRBase.BusinessGetSanPhamListException, ex);
            }
        }        

        public static SanPhamCollection GetSanPhamList(SanPhamColumns orderBy, OrderDirection orderDirection, int page, int pageSize, out int totalRecords)
        {            
            try
            {
                SanPhamDAO sanPhamDAO = new SanPhamDAO();
                return sanPhamDAO.GetSanPhamList(orderBy, orderDirection, page, pageSize, out totalRecords);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SRBase.BusinessGetSanPhamListException, ex);
            }
        }        
		
		
        #endregion
    }
}